/*
 * Created on Apr 14, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

package com.jjprojects.earutility;
import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 * @author U678864 TODO To change the template for this generated type comment
 *         go to Window - Preferences - Java - Code Style - Code Templates
 */
public class CustomFileChooserFilter extends FileFilter
{
    String strExtention = null;
    String strDisplayValue = null;

    public CustomFileChooserFilter(String strDisplayValue, String strExtention)
    {
        this.strExtention = strExtention;
        this.strDisplayValue = strDisplayValue;
    }

    public boolean accept(File file)
    {
        String filename = file.getName();

        if (file.isDirectory())
        {
            return true;
        }
        else if (filename.endsWith(this.strExtention))
        {
            return true;
        }
        else
        {
            if(this.strExtention.equals("*"))
            {
                if(filename.endsWith(".ear"))
                {
                    return true;
                }
                else if(filename.endsWith(".war"))
                {
                    return true;
                }
                else if(filename.endsWith(".jar"))
                {
                    return true;
                }
                else if(filename.endsWith(".zip"))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
    }

    public String getDescription()
    {
        return this.strDisplayValue;
    }
}